home *** CD-ROM | disk | FTP | other *** search
/ NBC Slam Jams! / NBC Slam Jams!.iso / xtras / media_la / set_fx.dir / 00101_Script_Compass Object < prev    next >
Text File  |  1998-01-20  |  4KB  |  143 lines

  1. property pCompassSprite, pArrowsSprite, pTextSprite, pTextField, pCurVal, pCallBackObj, pRefcon
  2. property pRange, pMin, pMax, pCenterPoint, pActive
  3.  
  4. on new me, propList
  5.   --pCompassSprite0, pArrowsSprite0, pTextSprite0, pTextField0, pCenterPoint0, pCurVal0, pCallBackObj0, pRefCon0
  6.   set pCompassSprite = getAProp(proplist,#lineSprite)
  7.   set pArrowsSprite = getAProp(proplist,#arrowsSprite)
  8.   set pTextSprite = getAProp(proplist,#textSprite)
  9.   set pTextField = getAProp(proplist,#textField)
  10.   set pCenterPoint = getAProp(proplist,#center)
  11.   set pMin = -720
  12.   set pMax = 720
  13.   set pCurVal = getAProp(proplist,#cur)
  14.   set pRange = pMax-pMin
  15.   
  16.   set pActive = getAProp(proplist,#active)
  17.   set pCallBackObj = getAProp(proplist,#callback)
  18.   set pRefCon = getAProp(proplist,#ref)
  19.   
  20.   setVal(me,pCurVal)
  21.   setEnabled(me,pActive)
  22.   
  23.   return(me)
  24. end
  25.  
  26. on wait me, waitTime
  27.   put the ticks into t
  28.   repeat while the ticks < t+waitTime
  29.   end repeat
  30. end
  31.  
  32. on Click me
  33.   if not pActive then exit
  34.   repeat while the stillDown
  35.     put the mouseH - the locH of sprite the clickOn into x
  36.     put the mouseV - the locV of sprite the clickOn into y
  37.     
  38.     if x = 0 then put -.0001 into x
  39.     
  40.     put atan(float(y)/x)+0.5*pi() into a
  41.     if x < 1 then put a+pi() into a
  42.     
  43.     put integer((a/(2*pi()))*360) into a
  44.     
  45.     if a > 180 then put a-360 into a
  46.     
  47.     setVal(me,a)
  48.     if objectP(pCallBackObj) then compassChange(pCallBackObj, pRefcon, a)
  49.     updateStage
  50.   end repeat
  51.   if objectP(pCallBackObj) then EndChange(pCallBackObj)
  52. end
  53.  
  54.  
  55. on Arrows me
  56.   if not pActive then exit
  57.   put the locH of the clickLoc into h1
  58.   put the locH of sprite the clickOn into h2
  59.   if h1 < h2 then
  60.     put "left" into side
  61.     put -1 into d
  62.   else
  63.     put "right" into side
  64.     put 1 into d
  65.   end if
  66.   set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
  67.   set newVal = max(min(pCurVal+d,pMax),pMin)
  68.   
  69.   if objectP(pCallBackObj) then compassChange(pCallBackObj, pRefcon, newVal)
  70.   updateStage
  71.   wait(me,5)
  72.   repeat while the stillDown
  73.     if rollover(pArrowsSprite) then
  74.       set the member of sprite pArrowsSprite = member ("horizArrows"&&side)
  75.       set pCurVal = max(min(pCurVal+d,pMax),pMin)
  76.     else
  77.       set the member of sprite pArrowsSprite = member "horizArrows"
  78.     end if
  79.     setVal(me,pCurVal)
  80.     if objectP(pCallBackObj) then compassChange(pCallBackObj, pRefcon, newVal)
  81.     wait(me,5)
  82.   end repeat
  83.   set the member of sprite pArrowsSprite = member "horizArrows"
  84.   if objectP(pCallBackObj) then EndChange(pCallBackObj)
  85. end
  86.  
  87.  
  88. on TextOut me
  89.   if the platform contains "Mac" then put numtochar(161) into degreeSymbol
  90.   else put numtochar(186) into degreeSymbol
  91.   if voidP(pCurVal) then put " " into field pTextField
  92.   else put string(integer(pCurVal))°reeSymbol into field pTextField
  93. end
  94.  
  95.  
  96. on SetVal me, newVal
  97.   puppetSprite pThumbSprite, TRUE
  98.   set pCurVal = newVal
  99.   drawLine(me)
  100.   TextOut(me)
  101.   --updateStage
  102. end
  103.  
  104. on drawLine me
  105.   puppetSprite pCompassSprite, TRUE
  106.   put (float(pCurVal)/360)*2*pi()-0.5*pi() into a
  107.   
  108.   put integer(cos(a)*14) into x
  109.   put integer(sin(a)*14) into y
  110.   
  111.   if x = 1 or x = 0 then
  112.     put 2 into x
  113.   else if x = -1 then
  114.     put -2 into x
  115.   else if y = 1 or y = 0 then
  116.     put 2 into y
  117.   else if y = -1 then
  118.     put -2 into y
  119.   end if
  120.   
  121.   put rect(pCenterPoint,pCenterPoint+point(x,y)) into r
  122.   if ((x < 0) and (y > 0)) or ((x > 0) and (y < 0)) then
  123.     set the castNum of sprite pCompassSprite = the number of cast "line2"
  124.   else
  125.     set the castNum of sprite pCompassSprite = the number of cast "line1"
  126.   end if  
  127.   set the rect of sprite pCompassSprite = r
  128.   --updateStage
  129. end
  130.  
  131. on SetEnabled me, enabled
  132.   set pActive = enabled
  133.   enableInterfaceElement(pCompassSprite,enabled)
  134.   enableInterfaceElement(pArrowsSprite,enabled)
  135.   enableInterfaceElement(pTextSprite,enabled)
  136. end
  137.  
  138. on Release me
  139.   -- release all puppets, constraints, etc.
  140. end
  141.  
  142.  
  143.